PandaDKP = LibStub("AceAddon-3.0"):NewAddon("PandaDKP", "AceConsole-3.0", "AceTimer-3.0", "AceComm-3.0", "AceEvent-3.0")

local PandaDKPDBver = 2.0

PandaDKP.DBDefaults =
{
   ["realm"] =
   {
      dbversion = PandaDKPDBver, -- Structure version of the SavedVariables DB
      ItemQuality = 4,
      LootScanning = false,
   }
}

local ldb = LibStub("LibDataBroker-1.1"):NewDataObject("PandaDKP", {
	type = "launcher",
	text = "Panda DKP",
	icon = "Interface\\Buttons\\UI-GroupLoot-Dice-Up",
})

function ldb.OnClick(self, button)
	if button == "RightButton" then
	   InterfaceOptionsFrame_OpenToCategory("Panda DKP")
	else
	   PandaDKP.Bidding:ShowWindow()
	end
end

function ldb.OnTooltipShow(tt)
	tt:AddLine("Panda DKP")
   tt:AddLine("|cffeda55fClick|r to open the bidding window. |cffeda55fRight-click|r to view configuration options.", 0.2, 1, 0.2)
end


-- Called when the addon is first loaded.
function PandaDKP:OnInitialize()
   -- Create the database
   self.db = LibStub("AceDB-3.0"):New("PandaDKPDB", self.DBDefaults)
   PandaDKP:RegisterChatCommand("pdkp", function() PandaDKP.Bidding:ShowWindow() end)
end


-- Called when the user enables the addon
function PandaDKP:OnEnable()
   -- Enable our sub-classes
   PandaDKP.Bidding:Enable()
   PandaDKP.Comm:Enable()
   PandaDKP.Config:Enable()
   PandaDKP.Looting:Enable()
   PandaDKP.Messages:Enable()
   
   -- Start processing the message queue
   PandaDKP.Messages:StartTimer()
end


-- Called when the user enables the addon
function PandaDKP:OnDisable()
   -- Stop processing the message queue
   PandaDKP.Messages:StopTimer()
end